<template>
  <div class="app-container">
    <!-- 基础信息 -->
    <h5 class="titleInfo">团队关系调整</h5>
    <el-form class="form" ref="form"  :model="form" label-width="136px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="美学设计师姓名">
            <span class="spanToInput">{{list.realName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="美学设计师手机号">
            <span class="spanToInput">{{list.username | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="美学设计师级别">
            <span class="spanToInput">{{list.roleName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="是否带团队"
            :rules="{
      required: true, message: '不能为空', trigger: 'blur'
    }"
          >
            <el-select placeholder="请选择" v-model="form.isWithTeam">
              <el-option
                v-for="item in teamOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="修改原因"
            :rules="{
      required: true, message: '不能为空', trigger: 'blur'
    }"
          >
            <el-input v-model="form.remark"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-button style="margin-top:30px" type="primary" @click="submitFn('form')">立即提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { updateTeamRelationship } from "@/api/subscribeManage";

export default {
  name: "designerInfoTeam",
  data() {
    return {
      val: "1",
      form: {},
      list: null,
      teamOption: [
        {
          label: "带团队",
          value: 0
        },
        {
          label: "不带团队",
          value: 1
        }
      ]
    };
  },
  inject: ["reload"],
  filters: {
    filterNull(e) {
      if (!e) {
        return "暂无";
      } else {
        return e;
      }
    }
  },
  created() {
    this.list = JSON.parse(this.$route.query.userId);
    this.form.userId = this.list.userId;
  },
  mounted() {},
  methods: {
    // 修改提交
    submitFn(e) {
      // console.log(this.form)
      if ((!this.form.isWithTeam && this.form.isWithTeam!='0') || !this.form.remark) {
        this.$message({
          showClose: true,
          message: "必选项不能为空"
        });
        return;
      }
      updateTeamRelationship(this.form)
        .then(res => {
          if (!res.data.code) {
            this.$message({
              showClose: true,
              message: "团队关系调整成功",
              type: "success"
            });
            this.$router.push("/designerManageIndex");
            this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
          // console.log(res)
        })
        .catch(error => {
          this.$message.error(error);
        });
    }
  }
};
</script>
<style scoped>
.app-container {
  padding: 0.1px !important;
}
</style>